define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'apply.warehouse/index',
        add_url: 'apply.warehouse/add',
        edit_url: 'apply.warehouse/edit',
        delete_url: 'apply.warehouse/delete',
        modify_url: 'apply.warehouse/modify',
    };

    var Controller = {

        index: function () {
            
            ea.table.render({
                init: init,
                defaultToolbar:['filter', {
                    title: '搜索',
                    layEvent: 'TABLE_SEARCH',
                    icon: 'layui-icon-search',
                    extend: 'data-table-id="' + 'warehouse' + '"'
                }],
                cols: [[
                    {type: "checkbox"},
                    {field: 'open_time', minWidth: 80, title: '开仓时间' , search: 'range'},
                    {field: 'type', minWidth: 80, title: '类型',templet:function(d){
                        if (d.type == 1) {
                            return '现价买入'
                        }else if(d.type == 2) {
                            return '现价卖出'
                        }else if(d.type == 3) {
                            return '到价买入'
                        }else if(d.type == 4) {
                            return '到价卖出'
                        }else if(d.type == 5) {
                            return '限价买入'
                        }else{
                            return '限价卖出'
                        }
                    }},
                    {field: 'position', minWidth: 80, title: '仓位'},
                    {field: 'stocks', minWidth: 80, title: '个股代码'},
                    {field: 'open_price', minWidth: 80, title: '开仓价'},
                    {field: 'stop_loss_price', minWidth: 80, title: '止损价'},
                    {field: 'stop_surplus_price', minWidth: 80, title: '止盈价'},
                    {field: 'profit', minWidth: 80, title: '利润点位'},
                    {field: 'strategic_basis', minWidth: 80, title: '策略依据'},
                    {field: 'analyst', minWidth: 80, title: '分析师'},
                    {field: 'create_time', minWidth: 80, title: '创建时间', search: 'range'},
                    {
                        width: 250,
                        title: '操作',
                        templet: ea.table.tool,
                    }
                ]],
            });

            

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        }
    };
    return Controller;
});